package org.example.im.dto;

import lombok.Data;

@Data
public class WebSocketMessage {
    
    private Integer type; // 0: 聊天消息, 1: 用户上线, 2: 用户下线, 3: 心跳检测
    private Object data; // 消息内容或用户信息
    
    // 用于创建聊天消息
    public static WebSocketMessage createChatMessage(Object data) {
        WebSocketMessage message = new WebSocketMessage();
        message.setType(0);
        message.setData(data);
        return message;
    }
    
    // 用于创建用户上线消息
    public static WebSocketMessage createUserOnlineMessage(Object data) {
        WebSocketMessage message = new WebSocketMessage();
        message.setType(1);
        message.setData(data);
        return message;
    }
    
    // 用于创建用户下线消息
    public static WebSocketMessage createUserOfflineMessage(Object data) {
        WebSocketMessage message = new WebSocketMessage();
        message.setType(2);
        message.setData(data);
        return message;
    }
    
    // 用于创建心跳检测消息
    public static WebSocketMessage createHeartbeatMessage() {
        WebSocketMessage message = new WebSocketMessage();
        message.setType(3);
        return message;
    }
} 